<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>css有意思</title>
  <style>
    .child-1 {
      color: var(--colorBlue);
      font-size: var(--fontSize);
    }
    .child-2 {
      color: var(--colorRed);
      font-size: var(--fontSizeTest);
    }
  </style>
  <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.9/vue.min.js"></script>
</head>
<body>
  <main class="container" id="app">   
    <h2>在 Vue 2 中使用CSS 变量</h2>
    <div class="hello" :style="styleVar">
      <div class="child-1">I am Child 1</div>
      <div class="child-2">I am Child 2</div>
      <div @click="changeFontSize">change Font Size</div>
    </div>

  </main>  
  <script>
    new Vue({
      el:'#app',      
      data: {
        styleVar: {
          "--colorBlue": "blue",
          "--colorRed": "red",
          "--fontSize": "30px",
          "--fontSizeTest": "30px",
        },
      },
      methods:{
        changeFontSize() {
          this.styleVar["--fontSizeTest"] = "40px";
        },
      }
    })
  </script>
</body>
</html>